package com.hsc.www.exchangeType.direct2;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class Config {

    public static final String DOG1_QUEUE = "dog1Queue";
    public static final String DOG2_QUEUE = "dog2Queue";
    public static final String DOG3_QUEUE = "dog3Queue";
    public static final String DOG1_ROUTING_KEY = "dog1RoutingKey";
    public static final String DOG2_ROUTING_KEY = "dog2RoutingKey";
    public static final String DOG3_ROUTING_KEY = "dog3RoutingKey";
    public static final String DOG_EXCHANGE = "dogExchange";


    @Bean(name = DOG_EXCHANGE)
    public DirectExchange exchange() {
        return new DirectExchange(DOG_EXCHANGE);
    }


    @Bean(name = DOG1_QUEUE)
    public Queue queue1() {
        return new Queue(DOG1_QUEUE);
    }

    @Bean(name = DOG2_QUEUE)
    public Queue queue2() {
        return new Queue(DOG2_QUEUE);
    }

    @Bean(name = DOG3_QUEUE)
    public Queue queue3() {
        return new Queue(DOG3_QUEUE);
    }


    @Bean
    Binding bindingExchangeMessage1(@Qualifier(DOG1_QUEUE) Queue queue, @Qualifier("dogExchange") DirectExchange exchange) {
        return BindingBuilder.bind(queue).to(exchange).with(DOG1_ROUTING_KEY);
    }

    @Bean
    Binding bindingExchangeMessage2(@Qualifier(DOG2_QUEUE) Queue queue, @Qualifier("dogExchange") DirectExchange exchange) {
        return BindingBuilder.bind(queue).to(exchange).with(DOG2_ROUTING_KEY);
    }

    @Bean
    Binding bindingExchangeMessage3(@Qualifier(DOG3_QUEUE) Queue queue, @Qualifier("dogExchange") DirectExchange exchange) {
        return BindingBuilder.bind(queue).to(exchange).with(DOG3_ROUTING_KEY);
    }

}